package com.scheduling.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.scheduling.common.annotation.Log;
import com.scheduling.common.core.controller.BaseController;
import com.scheduling.common.core.domain.AjaxResult;
import com.scheduling.common.enums.BusinessType;
import com.scheduling.system.domain.Personalizedrequests;
import com.scheduling.system.service.IPersonalizedrequestsService;
import com.scheduling.common.utils.poi.ExcelUtil;
import com.scheduling.common.core.page.TableDataInfo;

/**
 * 个性化诉求Controller
 * 
 * @author mj
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/system/personalizedrequests")
public class PersonalizedrequestsController extends BaseController
{
    @Autowired
    private IPersonalizedrequestsService personalizedrequestsService;

    /**
     * 查询个性化诉求列表
     */
    @PreAuthorize("@ss.hasPermi('system:personalizedrequests:list')")
    @GetMapping("/list")
    public TableDataInfo list(Personalizedrequests personalizedrequests)
    {
        startPage();
        List<Personalizedrequests> list = personalizedrequestsService.selectPersonalizedrequestsList(personalizedrequests);
        return getDataTable(list);
    }

    /**
     * 导出个性化诉求列表
     */
    @PreAuthorize("@ss.hasPermi('system:personalizedrequests:export')")
    @Log(title = "个性化诉求", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Personalizedrequests personalizedrequests)
    {
        List<Personalizedrequests> list = personalizedrequestsService.selectPersonalizedrequestsList(personalizedrequests);
        ExcelUtil<Personalizedrequests> util = new ExcelUtil<Personalizedrequests>(Personalizedrequests.class);
        util.exportExcel(response, list, "个性化诉求数据");
    }

    /**
     * 获取个性化诉求详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:personalizedrequests:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(personalizedrequestsService.selectPersonalizedrequestsById(id));
    }

    /**
     * 新增个性化诉求
     */
    @PreAuthorize("@ss.hasPermi('system:personalizedrequests:add')")
    @Log(title = "个性化诉求", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Personalizedrequests personalizedrequests)
    {
        return toAjax(personalizedrequestsService.insertPersonalizedrequests(personalizedrequests));
    }

    /**
     * 修改个性化诉求
     */
    @PreAuthorize("@ss.hasPermi('system:personalizedrequests:edit')")
    @Log(title = "个性化诉求", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Personalizedrequests personalizedrequests)
    {
        return toAjax(personalizedrequestsService.updatePersonalizedrequests(personalizedrequests));
    }

    /**
     * 删除个性化诉求
     */
    @PreAuthorize("@ss.hasPermi('system:personalizedrequests:remove')")
    @Log(title = "个性化诉求", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(personalizedrequestsService.deletePersonalizedrequestsByIds(ids));
    }
}
